Page({
  data: {
    nvabarData: {
      title: '上课记录',
      transmit: ''
    },
    records: [],
  },

  onLoad: function () {
    // 加载上课记录数据
    this.loadCourseRecords();
  },

  onShow: function () {
    // 页面显示时刷新数据
    this.loadCourseRecords();
  },

  // 加载上课记录
  loadCourseRecords: function() {
    // 模拟数据 - 实际开发中应从服务器获取
    const records = [
      {
        id: 1,
        courseName: '数学进阶课程',
        date: '2025-10-15',
        time: '14:00-15:30',
        deductedHours: 1,
        attended: true,
        teacher: '李老师',
        month: '2023年11月'
      },
      {
        id: 2,
        courseName: '英语口语训练',
        date: '2025-10-12',
        time: '10:00-11:30',
        deductedHours: 1,
        attended: true,
        teacher: '王老师',
        month: '2023年11月'
      },
      {
        id: 3,
        courseName: '物理实验课',
        date: '2025-10-08',
        time: '16:00-17:30',
        deductedHours: 0,
        attended: false,
        teacher: '张老师',
        month: '2023年11月'
      },
      {
        id: 4,
        courseName: '数学进阶课程',
        date: '2024-10-28',
        time: '14:00-15:30',
        deductedHours: 1,
        attended: true,
        teacher: '李老师',
        month: '2023年10月'
      },
      {
        id: 5,
        courseName: '英语口语训练',
        date: '2024-10-25',
        time: '10:00-11:30',
        deductedHours: 1,
        attended: true,
        teacher: '王老师',
        month: '2023年10月'
      },
      {
        id: 6,
        courseName: '数学进阶课程',
        date: '2024-10-24',
        time: '14:00-15:30',
        deductedHours: 1,
        attended: true,
        teacher: '李老师',
        month: '2023年10月'
      },
      {
        id: 7,
        courseName: '英语口语训练',
        date: '2024-10-23',
        time: '10:00-11:30',
        deductedHours: 1,
        attended: true,
        teacher: '王老师',
        month: '2023年10月'
      }
    ];

    this.setData({
      records,
    });
  },

  // 查看记录详情
  viewRecordDetail: function(e) {
    const record = e.currentTarget.dataset.record;
    wx.navigateTo({
      url: `/pages/course-records-detail/index?id=${record.id}`
    });
  }
});